package com.health.review.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.health.common.annotation.Log;
import com.health.common.core.controller.BaseController;
import com.health.common.core.domain.AjaxResult;
import com.health.common.enums.BusinessType;
import com.health.review.domain.ContentReview;
import com.health.review.service.IContentReviewService;
import com.health.common.utils.poi.ExcelUtil;
import com.health.common.core.page.TableDataInfo;

/**
 * 资讯审核Controller
 * 
 * @author moxxie
 * @date 2025-11-02
 */
@RestController
@RequestMapping("/review/review")
public class ContentReviewController extends BaseController
{
    @Autowired
    private IContentReviewService contentReviewService;

    /**
     * 查询资讯审核列表
     */
    @PreAuthorize("@ss.hasPermi('review:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContentReview contentReview)
    {
        startPage();
        List<ContentReview> list = contentReviewService.selectContentReviewList(contentReview);
        return getDataTable(list);
    }

    /**
     * 导出资讯审核列表
     */
    @PreAuthorize("@ss.hasPermi('review:review:export')")
    @Log(title = "资讯审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContentReview contentReview)
    {
        List<ContentReview> list = contentReviewService.selectContentReviewList(contentReview);
        ExcelUtil<ContentReview> util = new ExcelUtil<ContentReview>(ContentReview.class);
        util.exportExcel(response, list, "资讯审核数据");
    }

    /**
     * 获取资讯审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('review:review:query')")
    @GetMapping(value = "/{articleId}")
    public AjaxResult getInfo(@PathVariable("articleId") Long articleId)
    {
        return success(contentReviewService.selectContentReviewByArticleId(articleId));
    }

    /**
     * 新增资讯审核
     */
    @PreAuthorize("@ss.hasPermi('review:review:add')")
    @Log(title = "资讯审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContentReview contentReview)
    {
        return toAjax(contentReviewService.insertContentReview(contentReview));
    }

    /**
     * 修改资讯审核
     */
    @PreAuthorize("@ss.hasPermi('review:review:edit')")
    @Log(title = "资讯审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContentReview contentReview)
    {
        return toAjax(contentReviewService.updateContentReview(contentReview));
    }

    /**
     * 删除资讯审核
     */
    @PreAuthorize("@ss.hasPermi('review:review:remove')")
    @Log(title = "资讯审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{articleIds}")
    public AjaxResult remove(@PathVariable Long[] articleIds)
    {
        return toAjax(contentReviewService.deleteContentReviewByArticleIds(articleIds));
    }
}
